// mock模拟顶级分类相关的接口
import { topCategory } from '@/api/constans'
import Mock from 'mockjs'
const images = [
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(1).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(2).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(3).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(4).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(5).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(6).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(7).png',
  'http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/img/category%20(8).png'
]
export const getTopCategory = () => {
  return {
    msg: '获取成功',
    result: topCategory.map(item => {
      const children = []
      for (let i = 0; i < 10; i++) {
        children.push(
          Mock.mock({
            id: '@id',
            name: '@ctitle(2,4)',
            picture: images[Mock.mock('@integer(0,7)')]
          })
        )
      }
      return Mock.mock({
        name: item,
        id: '@id',
        children
      })
    })
  }
}
